package com.zxb.base.autoform.enm;

import cn.hutool.core.util.StrUtil;

/**
 * @author Zxb
 */
public enum ColumnSizeEnum {
    SINGLE_LINE_TEXT("单行文本", "NVARCHAR2", "255"),
    MULTI_LINE_TEXT("多行文本", "NVARCHAR2", "255"),
    RICH_TEXT("富文本", "NCLOB", null),
    NUMBER("数字", "NVARCHAR2", "255"),
    RADIO_BUTTON("单选框", "NUMBER", "4"),
    CHECKBOX_BUTTON("多选", "NVARCHAR2", "255"),
    SWITCH("开关", "NUMBER", "4"),
    DATE_CHOICE("日期选择", "DATE", null),
    DICTIONARIES("字典", "NVARCHAR2", "255"),
    ENUM_TYPE("枚举", "NVARCHAR2", "255"),
    PICTURE("图片", "NVARCHAR2", "255"),
    COMPUTATION_ATTRIBUTE("计算属性", "NVARCHAR2", "255"),
    DATA_SELECT("数据选择", "NVARCHAR2", "255");

    private final String name;
    private final String type;
    private final String size;

    ColumnSizeEnum(String name, String type, String size) {
        this.name = name;
        this.type = type;
        this.size = size;
    }

    public static boolean isExists(String name) {
        if (StrUtil.isBlank(name)) {
            return true;
        }
        ColumnSizeEnum[] values = ColumnSizeEnum.values();
        for (ColumnSizeEnum column : values) {
            if (name.equals(column.getName())) {
                return false;
            }
        }
        return true;
    }

    public static ColumnSizeEnum getSizeByName(String name) {
        if (StrUtil.isBlank(name)) {
            return null;
        }
        ColumnSizeEnum[] values = ColumnSizeEnum.values();
        for (ColumnSizeEnum column : values) {
            if (name.equals(column.getName())) {
                return column;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public String getType() {
        return type;
    }

    public String getSize() {
        return size;
    }

}
